package com.example.cenoo.itravel;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by Cenoo on 2017/6/28.
 */

public class BaseFragment extends Fragment {
    private static final String TAG = "BaseFragment";

    private int layoutRes;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle args = getArguments();
        layoutRes = args.getInt("layoutRes");
        Log.i(TAG, "onCreate().");
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(layoutRes, container, false);
        Log.i(TAG, "onCreateView().");
        return view;
    }

    public static BaseFragment newInstance(int layoutRes) {
        Bundle args = new Bundle();
        args.putInt("layoutRes", layoutRes);
        BaseFragment fragment = new BaseFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i(TAG, "onDestroy().");
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        Log.i(TAG, "onDestroyView().");
    }
}
